package com.csdj.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 周茜
 * @CreateTime: 2024-12-17
 * @Description:
 * @Version: 1.0
 */
@Configuration
public class MybatisPlusConfig {
    //    梳理：
//    1.注入MybatisPlusInterceptor 对象/bean
//    2.在MybatisPlusInterceptor bean加入分页插件 PaginationInnerInterceptor
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //注意：这里分页需要指定数据库类型，因为不同的db，分页的sql语句不同
        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return mybatisPlusInterceptor;
    }
}
